package com.janlei.thread;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 线程状态
 */
public class ThreadStateStu {

    private static ThreadStateStu stu;
    private static final ThreadLocal<SimpleDateFormat> formatter = new ThreadLocal<SimpleDateFormat>() {
        @Override
        protected SimpleDateFormat initialValue() {
            return new SimpleDateFormat("yyyyMMdd HHmm");
        }
    };

    public static ThreadStateStu getInstance() {
        if (stu == null) {
            synchronized (ThreadStateStu.class) {
                if (stu == null) {
                    stu = new ThreadStateStu();
                    return stu;
                }
            }
        }
        return stu;
    }

    private ThreadStateStu() {
    }

    public String formatDate(Date date) {
        return formatter.get().format(date);
    }
}
